package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface CheckGroupMapper {
@Delete("delete from health_chuanzhi.t_checkgroup_checkitem where checkgroup_id= #{id} ")
    void deleteById(int id);
/*@Select("select t.checkgroup_id from health_chuanzhi.t_setmeal_checkgroup t where setmeal_id=#{id}")
    ArrayList<Long> findCheckGroupIdsById(Long id);*/
@Select("select *from health_chuanzhi.t_checkgroup")
    ArrayList<CheckGroup> findAll();
/*查找废案---------------------------
@Select("select *from health_chuanzhi.t_checkgroup where id=#{id}")
    CheckGroup findById(Long id);*/

    //List<CheckGroup> getCheckGroup(CheckGroup checkGroup);
@Insert("insert into health_chuanzhi.t_checkgroup_checkitem(checkgroup_id, checkitem_id) values (#{G_i},#{id})")
    void addGroupById(Integer G_i, int id);

    @Options(useGeneratedKeys = true , keyProperty = "id")
    @Insert("insert into health_chuanzhi.t_checkgroup (code, name, helpCode, sex, remark, attention) " +
            "VALUES (#{code},#{name},#{helpCode},#{sex},#{remark},#{attention})")
    void addCheckGroup(CheckGroup checkGroup);

    Page<CheckGroup> pageQuery(String queryString);

    void update(CheckGroup checkGroup);
/*@Delete("delete from health_chuanzhi.t_setmeal_checkgroup where checkgroup_id=#{id}")
    void deleteSetmealByGoupId(Long id);*/

//借鉴大佬代码----------------------------
    List<CheckGroup> select(CheckGroup checkGroup);
}
